const cloudHelper = require('../../config/project_helpers_config').cloudHelper;

class ResearchProjectBiz {
  /**
   * 获取项目详情
   * @param {string} projectId 项目ID
   * @returns {Promise<object>} 项目详情
   */
  static async getProjectDetail(projectId) {
    if (!projectId) return null;
    
    try {
      const params = {
        id: projectId
      };
      
      const result = await cloudHelper.callCloudData('research_project/detail', params);
      return result;
    } catch (err) {
      console.error('[研发项目] 获取项目详情异常', err);
      throw err;
    }
  }

  /**
   * 获取项目的分支项目
   * @param {string} projectId 项目ID
   * @returns {Promise<Array>} 分支项目列表
   */
  static async getBranchProjects(projectId) {
    if (!projectId) return [];
    
    try {
      const params = {
        sourceId: projectId
      };
      
      const result = await cloudHelper.callCloudData('research_project/branch_list', params);
      return result.list || [];
    } catch (err) {
      console.error('[研发项目] 获取分支项目异常', err);
      return [];
    }
  }
}

module.exports = ResearchProjectBiz; 